<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
 <ui:composition template="/templates/Plantilla.xhtml">	
  <ui:define name="content">
   <h:form>
   <p:growl id="growl1" />			    
		<p:dataTable id="tblReparto" value="#{repartoList.repartos}" 
					 var="reparto">
			<f:facet name="header">Listado de Repartos</f:facet>
			<p:column>
   				<f:facet name="header">
   					<h:commandButton action="#{repartoList.nuevoReparto}" 
   					image="#{resource['images:plus-16-ns.png']}">			  
   					</h:commandButton>
   				</f:facet>
    				<h:commandButton type="submit" action="#{repartoList.prepareEdit(reparto)}" 
    				image="#{resource['images:pencil-16-ns.png']}">			    					
   				</h:commandButton>
   				
   			</p:column>
   			
   			<p:column>
   				<f:facet name="header">Nombre</f:facet>
   				#{reparto.nombre}
   			</p:column>
			<p:column>
   				<f:facet name="header">Clientes</f:facet>
   			</p:column>
   			<p:column>
   				<f:facet name="header">Repartidor</f:facet>
   				
   			</p:column>
   			<p:column>
   				<f:facet name="header">Vehiculo</f:facet>
   				#{reparto.vehiculo.patente}
   			</p:column>
   			<p:column>
   				<f:facet name="header"></f:facet>
    			<p:commandLink onclick="dlg2.show()" title="Eliminar Reparto" actionListener="#{repartoList.bajaListener(reparto)}" >
  					<p:graphicImage value="#{resource['images:cross-16-ns.png']}"/>
  					<p:ajax update="nombreEliminar"></p:ajax>
  				</p:commandLink>
   			</p:column>
		</p:dataTable>
		<p:dialog id="modalDialog" header="Eliminacion de Registro" widgetVar="dlg2" modal="true" resizable="false">  
    	
		  	<h:outputLabel value="¿Desea Eliminar el Reparto seleccionado?" />
			<p:separator/>	  
		    <p:commandButton id="confirm" value="Si" oncomplete="dlg2.hide()"  
		                  actionListener="#{repartoList.eliminarReparto()}" update="tblReparto" ajax="false"/>  
		    <p:commandButton id="decline" value="No" onclick="dlg2.hide()" type="button" ajax="false"/>
		</p:dialog>
	</h:form>			
 </ui:define>
</ui:composition>
</h:body>
</html>